// -*- C++ -*-
//===-- functional -------------------------------------------------------===//
//
// Copyright (C) 2019-2020 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This file incorporates work covered by the following copyright and permission
// notice:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//

#ifndef __ONEDPL_functional
#define __ONEDPL_functional

#include <functional>

#include "oneapi/dpl/utility"

namespace oneapi
{
namespace dpl
{
#if __cplusplus < 201703L
using ::std::binary_function;
using ::std::unary_function;
#endif
using ::std::binary_negate;
using ::std::bind;
using ::std::bit_and;
#if __cplusplus > 201103L
using ::std::bit_not;
#endif
using ::std::bit_or;
using ::std::bit_xor;
using ::std::cref;
using ::std::divides;
using ::std::equal_to;
using ::std::greater;
using ::std::greater_equal;
using ::std::less;
using ::std::less_equal;
using ::std::logical_and;
using ::std::logical_not;
using ::std::logical_or;
using ::std::minus;
using ::std::modulus;
using ::std::multiplies;
using ::std::negate;
using ::std::not1;
using ::std::not2;
using ::std::not_equal_to;
using ::std::plus;
using ::std::ref;
using ::std::reference_wrapper;
using ::std::unary_negate;

struct identity
{
    using is_transparent = void;

    template <typename _T>
    constexpr _T&&
    operator()(_T&& t) const noexcept
    {
        return ::std::forward<_T>(t);
    }
};

template <typename _T>
struct maximum
{
    constexpr const _T&
    operator()(const _T& a, const _T& b) const
    {
        return ::std::greater<_T>()(a, b) ? a : b;
    }
};

template <typename _T>
struct minimum
{
    constexpr const _T&
    operator()(const _T& a, const _T& b) const
    {
        return ::std::less<_T>()(a, b) ? a : b;
    }
};
} // end namespace dpl
} // end namespace oneapi

namespace dpl = oneapi::dpl;

#endif /* __DPSTD_functional */
